const fs = require("fs")
const path = require("path")

function copyFiles(copyFilesDir, newDir) {
  if (!fs.existsSync(newDir)) {
    fs.mkdirSync(newDir)
  }
  fs.readdir(copyFilesDir, {
    withFileTypes: true
  }, (err, files) => {
    console.log('file', files);
    files.forEach(f => {
      if (f.isFile()) {
        fs.copyFile(path.resolve(copyFilesDir, f.name), path.resolve(newDir, f.name), (e) => {
          console.log("文件拷贝完成");
        })
      } else {
        copyFiles(path.resolve(copyFilesDir, f.name), path.resolve(newDir, f.name))
      }
    })
  })
}
copyFiles("./zyw", "./zyw2")